/*
 * Copyright (c) 2024 endless-sky
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// Copyright (c) 2024 Endless Inc.
#pragma once

extern "C" {
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavutil/avutil.h>
}

#include <string>
#include <memory>

namespace El {
namespace Muxer {

class MP4Repair {
public:
    MP4Repair() = default;
    ~MP4Repair() = default;

    /**
     * 修复损坏的MP4文件
     * @param inputFile 输入文件路径
     * @param outputFile 输出文件路径,如果为空则覆盖输入文件
     * @return 是否修复成功
     */
    bool Repair(const std::string& inputFile, const std::string& outputFile = "");

private:
    bool RepairMoovAtom(const std::string& inputFile, const std::string& outputFile);
};

} // namespace Muxer
} // namespace El 